package code.tools.behavior.achieve 
{
	import code.tools.behavior.IAppear;
	import code.structure.manager.bitmap.YDisplayConvert;
	
	import com.greensock.TweenLite;
	import com.greensock.easing.Back;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	
	/**
	 * 逐渐变大
	 * @author CYang
	 */
	public class AppearScale implements IAppear
	{
		/**
		 * 面板引用
		 */
		private var _mPanel:Sprite;
		/**
		 * 面板出现后执行的操作
		 */
		private var _callBack:Function;
		
		
		
		private var tempImage:Bitmap;
		/**
		 * 构造函数
		 * @param	_mPanel 面板
		 * @param	callback 执行函数
		 */
		public function AppearScale(_mPanel:Sprite, callback:Function = null)
		{
			this._mPanel = _mPanel;
			this._callBack = callback;
			_mPanel.scaleX = _mPanel.scaleY = 0;
			_mPanel.visible = false;
		}
		/**
		 * 出现
		 */
		public function appear():void
		{
			_mPanel.visible = true;
			_mPanel.mouseEnabled = _mPanel.mouseChildren = false;
			TweenLite.to(_mPanel, 0.5, { scaleX:1, scaleY:1, ease:Back.easeOut,onComplete:completeHandler} );
		}
		
		private function completeHandler():void
		{
			_mPanel.mouseEnabled = _mPanel.mouseChildren = true;
			if (_callBack != null){
				_callBack();
			}
		}
		
	}
}